//Explicit Thread
#pragma once

#include "Register/TCR.h"

class ChipBus;
class CallbackBase;

struct ExplicitTimerCommand
{
	enum TYPE {ADD_EXPLICIT_TIMER, DELETE_EXPLICIT_TIMER};
	int type;
	UINT handler;
	UINT period;
	CallbackBase* callback;
};

struct Timer
{
	UINT period;
	LARGE_INTEGER beginTime;
	CallbackBase* callback;
};

class ExplicitBus
{
public:
	ExplicitBus(ChipBus& explicitQueue);
	void Run();

private:
	void AddTimer(UINT handler, UINT period, CallbackBase* callback);
	void DeleteTimer(UINT handler);
	void TriggerTimer(LARGE_INTEGER const& frequency);

	void OnCommand(bool& quitFlag);
	void ProcessCommand(bool& quitFlag);

private:
	ChipBus& m_queue;
 	map<UINT, Timer> m_timerMap;
};